#!usr/bin/env python  
# -*- coding:utf-8 _*-
'''
@author:robot
@file: data_copy_target_node.py 
@version:
@time: 2022/03/10 
'''
from TapClientCore.T04_logic.Dag02.node.data_copy_source_node import DataCopySourceNode


class DataCopySinkNode(DataCopySourceNode):
    def __init__(self, datasource_name):
        super().__init__(datasource_name)
        self.generate_node_sink(datasource_name)

    def generate_node_sink(self, datasource_name):
        from TapClientCore.T05_TM_feature.v2.TMF01_datasource.tmf_http import TMFHttp
        TMF = TMFHttp()
        # 通过datasource名称获取信息
        response = TMF.get_data_source_by_name(datasource_name)
        update_attr = {
            'syncObjects': [],
            # 'tablePrefix': '',
            # 'tableSuffix': '',
            # 'tableNameTransform': '',
            # 'fieldsNameTransform': '',
            # 'batchOperationList': [],
            'attrs': {
                'position': [
                    0,
                    200
                ],
                'connectionType': response.get('connection_type'),
                'pdkHash': response.get('pdkHash'),
                'pdkType': 'pdk',
                'connectionName': datasource_name,
                'isTarget': True
            },
        }
        self.node.update(update_attr)
